package MOLE.ui;

import MOLE.*;

/** 
 datatable ��ժҪ˵����
*/
public class datatable extends System.Web.UI.Page
{
	protected System.Web.UI.HtmlControls.HtmlGenericControl DIV1;
	protected System.Web.UI.WebControls.Button Button6;
	protected System.Web.UI.WebControls.Button btnFirst;
	protected System.Web.UI.WebControls.Button btnPre;
	protected System.Web.UI.WebControls.Button btnNext;
	protected System.Web.UI.WebControls.Button btnLast;
	protected System.Web.UI.WebControls.Label PageCurr;
	protected System.Web.UI.WebControls.Label recordCount;
	protected System.Web.UI.WebControls.Button btnSelectall;
	protected System.Web.UI.WebControls.Button btnDelSel;
	protected System.Web.UI.WebControls.DataGrid DataGrid1;

	private void Page_Load(Object sender, System.EventArgs e)
	{
		// �ڴ˴������û������Գ�ʼ��ҳ��
		DataTable t = new DataTable("Aim");

		//Add HEad
		t.Columns.Add(new DataColumn("clsname",java.lang.Class.forName("System.String")));
		t.Columns.Add(new DataColumn("flag", java.lang.Class.forName("System.Int32")));
		t.Columns.Add(new DataColumn("number", java.lang.Class.forName("System.Int32")));
		t.Columns.Add(new DataColumn("hoho"));


		for (int i = 0; i < 5; i++)
		{
			DataRow r = t.NewRow();
			r.setItem(0, "111");
			r.setItem(1, "222");
			r.setItem(2, "333");

			t.Rows.Add(r);
		}



		DataGrid1.DataSource = t;
		this.DataBind();

	}

//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
		///#region Web ������������ɵĴ���
	@Override
	protected void OnInit(EventArgs e)
	{
		//
		// CODEGEN: �õ����� ASP.NET Web ���������������ġ�
		//
		InitializeComponent();
		super.OnInit(e);
	}

	/** 
	 �����֧������ķ��� - ��Ҫʹ�ô���༭���޸�
	 �˷��������ݡ�
	*/
	private void InitializeComponent()
	{
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.btnSelectall.Click += new System.EventHandler(this.btnSelectall_Click);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.btnDelSel.Click += new System.EventHandler(this.btnDelSel_Click);
//C# TO JAVA CONVERTER TODO TASK: Java has no equivalent to C#-style event wireups:
		this.Load += new System.EventHandler(this.Page_Load);

	}
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
		///#endregion

	private void DataGrid1_SelectedIndexChanged(Object sender, System.EventArgs e)
	{

	}

	private void DataGrid1_EditCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
	{
		DataGrid1.EditItemIndex = e.Item.ItemIndex;
		Page_Load(null, null);
	}

	private void DataGrid1_CancelCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
	{
		DataGrid1.EditItemIndex = -1;
		Page_Load(null, null);
	}

	private void DataGrid1_UpdateCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
	{
		//			int  key=int.Parse( e.Item.Cells[1].Text.Trim() );
		//			string name=((TextBox)  e.Item.Cells[2].Controls[1]).Text;
		//			string tel=((TextBox)  e.Item.Cells[3].Controls[1]).Text;
		//			string groupid=((DropDownList)  e.Item.Cells[4].Controls[1]).SelectedValue;
		//			lblMsg.Text=(name+":"+tel+":"+groupid);
		//
		// 
		//			MOLE.SQL_DBOS o=new MOLE.SQL_DBOS("sms_telbook","");
		//			o.add("name",name);
		//			o.add("tel",tel);
		//			o.add("groupid",groupid);
		//			//	o.add("groupname",name);
		//			o.Update("id",key);
		//
		DataGrid1.EditItemIndex = -1;
		Page_Load(null, null);
	}

	private void DataGrid1_DeleteCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
	{
		//			int  key=int.Parse( e.Item.Cells[1].Text.Trim() );
		//			string sql="delete sms_telbook where id="+key.ToString();
		//			MOLE.SQL.ExecuteSql(sql);
		//		 
		//			 
		//			data();
	}

	private void DataGrid1_ItemDataBound(Object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
	{
		//			string s=e.Item.ItemIndex.ToString();
		//			new cs.log(s+"*********");
		//			if(e.Item.ItemIndex==-1)return;
		//
//			ItemCreated��ItemDataBound 
//				���ʹ��Repeater��ʱ������һ������.ҳ������һ��Repeater,��Ϊ�������һ��ItemCreated�¼�:
		 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

		 {

			//            Label body = e.Item.FindControl("lbBody") as Label;
			//
			//            string bodyText = ((Post)e.Item.DataItem).Body;
			//
			//            if (bodyText.Length > 20)
			//
			//            {
			//
			//                body.Text = bodyText.Substring(0, 20) + "����";
			//
			//            }
			//
			//            else
			//
			//                body.Text = bodyText;

		 }


		//Ŀ����Ϊ������ʾ���ݵ�ʱ���������һ��Ķ�.
		//
		//����,ÿ��ҳ��ص���ʱ��ͻ��������: DataItemΪ��ֵ.���ŷ���,ItemCreated��ItemDataBound���������:
		//
		//ItemCreated��ÿ��Repeater Render��ʱ�򶼻����,��ItemDataBound��һ��,ֻ�е�����DataBind(),��Ҫ�������ݰ󶨵�ʱ��Ż����.
		//
		//�м�!


		//			try
		//			{
		//				Button xx=(Button)  e.Item.FindControl("btnDel");
		//				xx.Attributes.Add("onclick","return confirm(\"�Ƿ�ɾ��\")");
		//			}
		//			catch{}
		//			try
		//			{
		//				//				 
		//				 
		//				string zuid=e.Item.Cells[7].Text;
		//				string id=e.Item.Cells[1].Text;
		//				DropDownList d=(DropDownList)e.Item.FindControl("ddlEdit");
		// 			
		//				DataTable dt =new cs.Group().Look();
		//				d.DataSource=dt;
		//				d.DataTextField="groupname";
		//				d.DataValueField="id";	
		//				d.DataBind();
		//				//d.SelectedValue="123";
		//				 
		//				 
		//				d.Items.FindByValue(zuid).Selected=true;
		// 
		//			}
		//			catch(Exception ee)
		//			{
		//				string ss=e.Item.ItemIndex.ToString();
		//				new cs.log(ss+"*********"+ee.ToString());
	}


	private void btnSelectall_Click(Object sender, System.EventArgs e)
	{
//			DataGrid1.EditItemIndex=-1;
//			data();
//			for(int   i=0;i<DataGrid1.Items.Count;i++)   
//			{   
//				CheckBox   c1=(CheckBox)DataGrid1.Items[i].Cells[0].Controls[1];  
//				if(btnSelectall.Text=="ȫѡ")	
//				{
//					c1.Checked   =   true;  
//					
//				}
//				else
//				{
//					c1.Checked=false;
//					 
//				}
//
//			}
//			if(btnSelectall.Text=="ȫѡ")	
//				btnSelectall.Text="ȫ��ѡ";
//			else
//				btnSelectall.Text="ȫѡ";

	}

	private void btnDelSel_Click(Object sender, System.EventArgs e)
	{
//			string delid="";
//			for(int   i=0;i<DataGrid1.Items.Count;i++)   
//			{ 
//				try
//				{
//					CheckBox   c1=(CheckBox)DataGrid1.Items[i].Cells[0].Controls[1];   
//					if(c1.Checked)   
//					{   
//						delid=delid +","+ DataGrid1.Items[i].Cells[1].Text.Trim();
//					}   
//
//				}
//				catch{}
//
//			}
//			if(delid=="")return;
//			delid=delid.Substring(1);
//			//	if(delid=="")return;
//			//delid=int.Parse(delid);
//			//Label2.Text=delid;
//			new cs.Telbook().Del(delid);
//
//
//			try
//			{
//				DataGrid1.CurrentPageIndex=DataGrid1.PageCount-2;
//			}
//			catch{DataGrid1.CurrentPageIndex=0;}
//			data();

	}

}